<template>
  <div>
    <h1>登录</h1>
       <el-form>
          <el-form-item label="卡号">
            <el-input v-model.number="card.num"></el-input>
          </el-form-item>
         <el-form-item label="密码">
           <el-input v-model.trim="card.pwd"></el-input>
         </el-form-item>
         <el-button type="success" icon="el-icon-success" @click="login">登录</el-button>
       </el-form>
  </div>
</template>

<script>
export default {
  name: "Login",
  data(){
    return{
      card:{
        num:'',
        pwd: ''
      }
    }
  },
  methods:{
     login(){
        this.postRequest("user/login?cardnum="+this.card.num+"&password="+this.card.pwd)
            .then(resp=>{
               console.log(resp.data);
               if(resp.data.flag){
                  //保存用户信息
                  window.sessionStorage.setItem("card", JSON.stringify( resp.data.data));
                  //
                 this.$router.push("/books");
               }else{
                 this.$message(resp.data.message);
               }
            })
     }
  }
}
</script>

<style scoped>

</style>
